Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made BuildColorMaps redundant by using static tables #5289

Merged
merged 14 commits into from
Sep 10, 2024

Conversation

pkmnsnfrn
Copy link
Collaborator

@pkmnsnfrn pkmnsnfrn commented Aug 30, 2024

Description

Gif of weather changing without BuildColorMaps

  • Made BuildColorMaps redundant by using static tables

Usage

This feature is automatically used and requires no input from the developer or user.

Functionality

First, open include/field_weather.h. We're in here to remove the color maps from struct Weather, since they will be const data in ROM now. As a bonus, this frees up 1216 bytes in EWRAM! That's 0.46%!

When the player enters a new map in vanilla, the BuildColorMaps() function does a lot of expensive computations to create color maps used to transform palette colors for weather effects. These computations however, produce the same arrays every time they are run.

This PR will save the wasted computation by precomputing these color maps and removing the function altogether. This has the bonus effect of reducing EWRAM from 244554 B to 243338 B (a 0.4972% decrease)!

Testing

Clean Branch

You can recreate this branch by applying a patch or pulling the repo. From a clean version of expansion's upcoming, you can either:

Patch

wget https://files.catbox.moe/iqknfq.patch -O color.patch ; git apply color.patch ; rm color.patch

Repo

git remote add psf-expansion https://github.com/PokemonSanFran/pokeemerald-expansion/ ; git pull psf-expansion removeColorMaps

Manual Tests

Manual Testing

  • Compile
  • Start a new game
  • Utilties > Cheat Start
  • Utilties > Fly to Map
  • Fly to Mauville City
  • Utilties > Set Weather
  • Cycle through the different weathers

Verified Scenarios

All videos attempt to show all the weathers from SUNNY_CLOUDS through UNDERWATER_BUBBLES using the Manual Testing list.

Static Tables (this PR)

true.mp4

Build Color Maps (vanilla)

false2.mp4

People who collaborated with me in this PR

This was originally written by by @Deokishisu. @ShinyDragonHunter assisted with DOWP.

Discord Contact Info

I am pkmnsnfrn on Discord.

@pkmnsnfrn pkmnsnfrn added type: cleanup category: overworld Pertains to out-of-battle mechanics type: refactor labels Aug 30, 2024
include/config/overworld.h Outdated Show resolved Hide resolved
src/field_weather.c Outdated Show resolved Hide resolved
src/field_weather.c Outdated Show resolved Hide resolved
@Bassoonian Bassoonian merged commit 2477f1d into rh-hideout:upcoming Sep 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants